﻿Imports System.Net.Mail
Imports System.Net.Mime
Imports System.Net
Public Class CADASTRO
    Private Sub emailvisita(ByVal comercial As String, ByVal opcomercial As String)
        Dim m_htmlDoc As mshtml.IHTMLDocument2
        Dim htmlEditor As New WebBrowser
        htmlEditor.Navigate("about:blank")
        Dim TEXTO As String = opcomercial & ",<br><br>Visita agendada no dia" & DATAVISITAMaskedTextBox.Text & " por " & OPERADORComboBox.Text & " na empresa " & RAZAOTextBox.Text & " com " & CONTATOTextBox.Text & " no endereço: " & ENDTextBox.Text & " " & BAIRROTextBox.Text & " e com histórico abaixo: <br><br>" & HISTORICORichTextBox.Text & "<br><br>Atenciosamente,<br><br>"
        Dim assin As String = LoginForm1.ASSINATURATextBox.Text
        htmlEditor.Document.Write(TEXTO)
        m_htmlDoc = CType(htmlEditor.Document.DomDocument, mshtml.IHTMLDocument2)
        Dim PESSOA As String
        PESSOA = LoginForm1.NOMEMAILTextBox.Text
        Dim message As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()
        message.To.Add(comercial)
        message.From = New System.Net.Mail.MailAddress(LoginForm1.EMAILTextBox.Text, PESSOA)
        message.Bcc.Add(LoginForm1.EMAILTextBox.Text)
        message.CC.Add("janaina@vitoriafomento.com.br")
        message.CC.Add("cristiano@vitoriafomento.com.br")
        message.CC.Add("daniela@vitoriafomento.com.br")
        message.Subject = "Agendamento de Visita " & RAZAOTextBox.Text
        message.IsBodyHtml = True
        If String.IsNullOrEmpty(assin) Then
            message.Body = m_htmlDoc.body.innerHTML
        Else
            'Dim plainView As AlternateView = AlternateView.CreateAlternateViewFromString(m_htmlDoc.body.innerHTML & "<br><img src=cid:companylogo>", Nothing, "text/plain")
            Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(m_htmlDoc.body.innerHTML & "<br><img src=cid:companylogo>", Nothing, "text/html")
            Dim logo As New LinkedResource(assin)
            logo.ContentId = "companylogo"
            htmlView.LinkedResources.Add(logo)
            message.AlternateViews.Add(htmlView)
            'message.AlternateViews.Add(plainView)
        End If
        Dim smtp As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient()
        smtp.Host = "smtp.vitoriafomento.com.br"
        smtp.Port = 587
        smtp.Credentials = New System.Net.NetworkCredential(LoginForm1.EMAILTextBox.Text, LoginForm1.SENHAEMAILTextBox.Text)
        Try
            smtp.Send(message)
            MessageBox.Show("E-mail enviado com sucesso!")
            Cursor.Current = Cursors.Default
        Catch ex As Exception
            MessageBox.Show("Ocorreu um erro favor verificar os dados digitados " + ex.ToString)
        End Try
    End Sub
    Private Sub LISTAITENS(ByVal path As String)
        Try
            If IO.File.Exists(path) Then
                Using sr As New IO.StreamReader(path)
                    While Not sr.EndOfStream
                        RAMOComboBox.Items.Add(sr.ReadLine)
                    End While
                End Using
            Else
                MsgBox("Oooops, Arquivo não encontrado ou diretório inválido" & path.ToString)
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Function BuscaCep(ByVal cep As String) As Hashtable
        Dim ds As DataSet
        Dim _resultado As String
        Dim ht As System.Collections.Hashtable
        Try
            ds = New DataSet()
            ds.ReadXml("http://cep.republicavirtual.com.br/web_cep.php?cep=" + cep.Replace("-", "").Trim() + "&formato=xml")
            If Not IsNothing(ds) Then
                If (ds.Tables(0).Rows.Count > 0) Then
                    _resultado = ds.Tables(0).Rows(0).Item("resultado").ToString()
                    ht = New Hashtable
                    Select Case _resultado
                        Case "1"
                            CIDADETextBox.Text = ds.Tables(0).Rows(0).Item("cidade").ToString().Trim().ToUpper
                            BAIRROTextBox.Text = ds.Tables(0).Rows(0).Item("bairro").ToString().Trim().ToUpper
                            ENDTextBox.Text = ds.Tables(0).Rows(0).Item("tipo_logradouro").ToString().Trim().ToUpper + " " + ds.Tables(0).Rows(0).Item("logradouro").ToString().Trim().ToUpper
                            ENDTextBox.Enabled = True
                            BAIRROTextBox.Enabled = True
                            CIDADETextBox.Enabled = True
                        Case "2"
                            CIDADETextBox.Text = ds.Tables(0).Rows(0).Item("cidade").ToString().Trim().ToUpper
                            ENDTextBox.Enabled = True
                            BAIRROTextBox.Enabled = True
                            CIDADETextBox.Enabled = True
                    End Select
                End If
            End If
            Return ht
        Catch ex As Exception
            Throw New Exception("Falha ao Buscar o Cep" & vbCrLf & ex.ToString)
            ENDTextBox.Enabled = True
            CIDADETextBox.Enabled = True
            BAIRROTextBox.Enabled = True
            Return Nothing
        End Try
    End Function
    Private Sub CADASTRO_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        Select Case e.KeyCode
            Case Keys.Enter
                SendKeys.Send("{Tab}")
        End Select
    End Sub
    Private Sub CADASTRO_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DISTRICOMERCIALTextBox.Hide()
        Me.LOGINTableAdapter.Fill(Me.LOGINDataSet.LOGIN)
        Me.CADASTROTableAdapter.Fill(Me.CADASTRODataSet.CADASTRO)
        Try
            LISTAITENS("\\SERVIDOR1\Publico Administrativo\Público Administrativo\FUNIL DE VENDAS\RAMO.txt")
        Catch EX As Exception
            MsgBox("ERRO AO PREECHER COMBOBOX COM O RAMO PORÉM NÃO IMPACTUA NO FUNCIONAMENTO DO PROGRAMA")
        End Try

        Select Case LoginForm1.GRUPOComboBox.Text
            Case "USUARIO"
                CADASTROTableAdapter.FillByAGENDAOPERADOR(CADASTRODataSet.CADASTRO, DateValue(Now), LoginForm1.USUARIOTextBox.Text)
                If CADASTRODataSet.Tables(0).Rows.Count > 0 Then
                    MsgBox(LoginForm1.USUARIOTextBox.Text & " EXISTEM " & CADASTRODataSet.Tables(0).Rows.Count & " AGENDAMENTOS ATRASADOS ")
                    RAZAOTextBox.Focus()
                Else
                    MsgBox(LoginForm1.USUARIOTextBox.Text & " NÃO EXISTE AGENDAMENTOS ATRASADOS")
                    RAZAOTextBox.Focus()
                End If
                Button11.Enabled = False
            Case "COMERCIAL"
                Button11.Enabled = False
                OPERADORComboBox.Enabled = True
                Button13.Enabled = True
                CADASTROTableAdapter.FillByAGENDACOMERCIAL(CADASTRODataSet.CADASTRO, DateValue(Now), LoginForm1.USUARIOTextBox.Text)
                If CADASTRODataSet.Tables(0).Rows.Count > 0 Then
                    MsgBox(LoginForm1.USUARIOTextBox.Text & " EXISTEM " & CADASTRODataSet.Tables(0).Rows.Count & " AGENDAMENTOS ATRASADOS ")
                    RAZAOTextBox.Focus()
                Else
                    MsgBox(LoginForm1.USUARIOTextBox.Text & " NÃO EXISTE AGENDAMENTOS ATRASADOS")
                    RAZAOTextBox.Focus()
                End If
            Case "MASTER"
                Button11.Enabled = True
                Button13.Enabled = True
                OPERADORComboBox.Enabled = True
                COMERCIALComboBox.Enabled = True
                NCONTATOTextBox.ReadOnly = False
                NCONTATOTextBox.Enabled = True
                DELETAR.Enabled = True
                HISTORICORichTextBox.ReadOnly = False
                CADASTROTableAdapter.FillByMENORAGENDA(CADASTRODataSet.CADASTRO, DateValue(Now))
                If CADASTRODataSet.Tables(0).Rows.Count > 0 Then
                    MsgBox(LoginForm1.USUARIOTextBox.Text & " EXISTEM " & CADASTRODataSet.Tables(0).Rows.Count & " AGENDAMENTOS ATRASADOS ")
                    RAZAOTextBox.Focus()
                Else
                    MsgBox(LoginForm1.USUARIOTextBox.Text & " NÃO EXISTE AGENDAMENTOS ATRASADOS")
                    RAZAOTextBox.Focus()
                End If
        End Select
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        EMAILFUNIL.MdiParent = Principal
        EMAILFUNIL.Show()
    End Sub
    Private Sub PRIMEIRO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PRIMEIRO.Click
        CADASTROBindingSource1.MoveFirst()
    End Sub
    Private Sub VOLTAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VOLTAR.Click
        CADASTROBindingSource1.MovePrevious()
    End Sub
    Private Sub NOVO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NOVO.Click
        ULTIMOCOMERCIALTableAdapter.Fill(Me.COMERCIALDataSet.ULTIMOCOMERCIAL)
        CADASTROBindingSource1.AddNew()
        ENDTextBox.Enabled = False
        BAIRROTextBox.Enabled = False
        CIDADETextBox.Enabled = False
        NCONTATOTextBox.Text = 0
        OPERADORComboBox.Text = LoginForm1.USUARIOTextBox.Text
        SITUACAOComboBox.Text = "EM PROSPECÇÃO"
        If LoginForm1.GRUPOComboBox.Text = "COMERCIAL" Then
            COMERCIALComboBox.Text = LoginForm1.USUARIOTextBox.Text
        Else
            Select DISTRICOMERCIALTextBox.Text
                Case "ADELAINE"
                    COMERCIALComboBox.Text = "RAFAEL"
                Case "RAFAEL"
                    COMERCIALComboBox.Text = "ADELAINE"
            End Select
        End If
        RAZAOTextBox.Focus()
    End Sub
    Private Sub DELETAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DELETAR.Click
        Try
            If MsgBox("DESEJA DELETAR O REGISTRO?", MsgBoxStyle.OkCancel, "ATENÇÃO") = MsgBoxResult.Ok Then
                Me.Validate()
                CADASTROBindingSource1.RemoveCurrent()
                CADASTROTableAdapter.Update(CADASTRODataSet.CADASTRO)
            End If
        Catch EX As Exception
            MsgBox("ERRO AO DELETAR O REGISTRO " & EX.ToString)
        End Try
    End Sub
    Private Sub FRENTE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FRENTE.Click
        CADASTROBindingSource1.MoveNext()
    End Sub
    Private Sub ULTIMO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ULTIMO.Click
        CADASTROBindingSource1.MoveLast()
    End Sub
    Private Sub SALVAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SALVAR.Click
        If IDTextBox.Text < 0 Then
            DISTRICOMERCIALTextBox.Text = COMERCIALComboBox.Text
            Me.Validate()
            ULTIMOCOMERCIALBindingSource.EndEdit()
            TableAdapterManager2.UpdateAll(COMERCIALDataSet)
        End If
        If RAZAOTextBox.Text = "" Or TELEFONETextBox.Text = "" Then
            MsgBox("FAVOR INFORMAR RAZÃO SOCIAL/TELEFONE")
        ElseIf LoginForm1.GRUPOComboBox.Text = "USUARIO" And AGENDAMENTOMaskedTextBox.Text < DateValue(Now) Or AGENDAMENTOMaskedTextBox.Text = "  /  /" Then
            MsgBox("FAVOR INFORMAR UMA DATA DE AGENDAMENTO VÁLIDA")
        ElseIf SITUACAOComboBox.Text = "" Then
            MsgBox("FAVOR INFORMAR A SITUAÇÃO DO CLIENTE", MsgBoxStyle.Information, "ATENÇÃO")
        Else
            If OPERADORComboBox.Text = "" Then
                OPERADORComboBox.Text = LoginForm1.USUARIOTextBox.Text
            End If
            If RichTextBox1.Text = "" Then
                HISTORICORichTextBox.Text = HISTORICORichTextBox.Text
                ULTCONTATOMaskedTextBox.Text = ULTCONTATOMaskedTextBox.Text
            Else
                HISTORICORichTextBox.Text = HISTORICORichTextBox.Text + "EM " + DateValue(Now) + " POR " + LoginForm1.USUARIOTextBox.Text + Environment.NewLine + RichTextBox1.Text + Environment.NewLine
                NCONTATOTextBox.Text = NCONTATOTextBox.Text + 1
                ULTCONTATOMaskedTextBox.Text = DateValue(Now)
            End If
            Try
                Me.Validate()
                CADASTROBindingSource1.EndEdit()
                TableAdapterManager.UpdateAll(CADASTRODataSet)
                CADASTROTableAdapter.FillByRAZAO(CADASTRODataSet.CADASTRO, RAZAOTextBox.Text)
                ENDTextBox.Enabled = False
                BAIRROTextBox.Enabled = False
                CIDADETextBox.Enabled = False
                RichTextBox1.Text = ""
            Catch EX As Exception
                MsgBox("ERRO NA ATUALIZAÇÃO DOS DADOS " + Environment.NewLine + EX.Message)
            End Try
        End If
        If VISITAAGENComboBox.Text = "SIM" Then
            If DATAVISITAMaskedTextBox.Text >= DateValue(Now) Then
                If MsgBox("DESEJA ENVIAR EMAIL PARA O COMERCIAL INFORMANDO SOBRE A VISITA?", MsgBoxStyle.YesNo, "Atenção") = MsgBoxResult.Yes Then
                    If COMERCIALComboBox.Text = "" Then
                        MsgBox("Favor solicitar a inclusão do comercial responsável", MsgBoxStyle.Information, "Atenção")
                    ElseIf COMERCIALComboBox.Text = "RAFAEL" Then
                        Try
                            emailvisita("rafael@vitoriafomento.com.br", "Rafael")
                            Cursor.Current = Cursors.WaitCursor
                        Catch ex As Exception
                            MsgBox("Erro ao enviar o email" + Environment.NewLine + ex.ToString, MsgBoxStyle.Information, "Atenção")
                        End Try
                    ElseIf COMERCIALComboBox.Text = "ADELAINE" Then
                        Try
                            emailvisita("adelaine@vitoriafomento.com.br", "Adelaine")
                            Cursor.Current = Cursors.WaitCursor
                        Catch ex As Exception
                            MsgBox("Erro ao enviar o email" + Environment.NewLine + ex.ToString, MsgBoxStyle.Information, "Atenção")
                        End Try
                    End If
                End If
            End If
        End If
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If RAZAOTextBox.Text = "" Then
            MsgBox("FAVOR INFORMAR A RAZÃO SOCIAL")
        Else
            CADASTROTableAdapter.FillByRAZAO(CADASTRODataSet.CADASTRO, RAZAOTextBox.Text)
        End If
    End Sub
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If ULTCONTATOMaskedTextBox.Text = "  /  /" Then
            MsgBox("FAVOR INFORMAR A DATA DO ÚLTIMO CONTATO")
        Else
            CADASTROTableAdapter.FillByULTCONTATO(CADASTRODataSet.CADASTRO, ULTCONTATOMaskedTextBox.Text)
        End If
    End Sub
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        CADASTROTableAdapter.FillByPRAHJ(CADASTRODataSet.CADASTRO, DateValue(Now))
    End Sub
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        If AGENDAMENTOMaskedTextBox.Text = "  /  /" Then
            MsgBox("FAVOR INFORMAR A DATA DO AGENDAMENTO")
        Else
            CADASTROTableAdapter.FillByAGENDAMENTO(CADASTRODataSet.CADASTRO, AGENDAMENTOMaskedTextBox.Text)
        End If
    End Sub
    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        If String.IsNullOrEmpty(DATAVISITAMaskedTextBox.Text) Then
            MsgBox("FAVOR INFORMAR A DATA DA VISITA E O HORÁRIO")
        Else
            CADASTROTableAdapter.FillByDATAVISITA(CADASTRODataSet.CADASTRO, DATAVISITAMaskedTextBox.Text)
        End If
    End Sub
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        If LoginForm1.GRUPOComboBox.Text = "MASTER" Then
            CADASTROTableAdapter.FillByOPERADOR(CADASTRODataSet.CADASTRO, OPERADORComboBox.Text)
        Else
            CADASTROTableAdapter.FillByOPERADOR(CADASTRODataSet.CADASTRO, LoginForm1.USUARIOTextBox.Text)
        End If
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        CADASTROTableAdapter.Fill(CADASTRODataSet.CADASTRO)
    End Sub
    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        Dim CalForm As New Form
        Dim Cal As New MonthCalendar
        Cal.MaxSelectionCount = 1
        CalForm.Controls.Add(Cal)
        CalForm.ClientSize = Cal.Size
        CalForm.Height += 24
        CalForm.Width += 50
        CalForm.MinimizeBox = False
        CalForm.MaximizeBox = False
        CalForm.MinimumSize = CalForm.Size
        CalForm.MaximumSize = CalForm.Size
        CalForm.ShowDialog()
        AGENDAMENTOMaskedTextBox.Text = Cal.SelectionRange.Start.ToString
        CalForm.Close()
        CalForm.Dispose()
        CalForm = Nothing
        Cal.Dispose()
        Cal = Nothing
    End Sub
    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.Checked = True Then
            ENDTextBox.Enabled = True
            CIDADETextBox.Enabled = True
            BAIRROTextBox.Enabled = True
        Else
            ENDTextBox.Enabled = False
            CIDADETextBox.Enabled = False
            BAIRROTextBox.Enabled = False
        End If
    End Sub
    Private Sub VISITAAGENComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VISITAAGENComboBox.SelectedIndexChanged
        If VISITAAGENComboBox.Text = "SIM" Then
            DATAVISITAMaskedTextBox.Enabled = True
            VISITADOComboBox.Enabled = True
        Else
            DATAVISITAMaskedTextBox.Enabled = False
            VISITADOComboBox.Enabled = False
        End If
    End Sub
    Private Sub CEPMaskedTextBox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles CEPMaskedTextBox.LostFocus
        BuscaCep(CEPMaskedTextBox.Text)
    End Sub
    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        MAPS.MdiParent = Principal
        MAPS.Show()
    End Sub
    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        If SITUACAOComboBox.Text = "" Then
            MsgBox("FAVOR INFORMAR A SITUAÇÃO")
        Else
            CADASTROTableAdapter.FillBySITUACAO(CADASTRODataSet.CADASTRO, SITUACAOComboBox.Text)
        End If
    End Sub
    Private Sub OPERADORTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        If LoginForm1.GRUPOComboBox.Text = "MASTER" Then
            DELETAR.Enabled = True
        End If
    End Sub
    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        CADASTROTableAdapter.FillByAGENDAOPERADOR(CADASTRODataSet.CADASTRO, DateValue(Now), LoginForm1.USUARIOTextBox.Text)
    End Sub
    Private Sub RAZAOTextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RAZAOTextBox.KeyDown
        Dim RAZAO As String
        If e.KeyCode = Keys.Enter Then
            RAZAO = RAZAOTextBox.Text
            CADASTROTableAdapter.FillByRAZAO(CADASTRODataSet.CADASTRO, RAZAOTextBox.Text)
            If CADASTRODataSet.Tables(0).Rows.Count > 0 Then
                MsgBox("EMPRESA JÁ CADASTRADA", MsgBoxStyle.Information, "Atenção")
            ElseIf MsgBox("EMPRESA NÃO CADASTRADA,DESEJA CADASTRALA AGORA?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                ULTIMOCOMERCIALTableAdapter.Fill(Me.COMERCIALDataSet.ULTIMOCOMERCIAL)
                CADASTROBindingSource1.AddNew()
                ENDTextBox.Enabled = False
                BAIRROTextBox.Enabled = False
                CIDADETextBox.Enabled = False
                NCONTATOTextBox.Text = 0
                OPERADORComboBox.Text = LoginForm1.USUARIOTextBox.Text
                SITUACAOComboBox.Text = "EM PROSPECÇÃO"
                If LoginForm1.GRUPOComboBox.Text = "COMERCIAL" Then
                    COMERCIALComboBox.Text = LoginForm1.USUARIOTextBox.Text
                Else
                    Select DISTRICOMERCIALTextBox.Text
                        Case "ADELAINE"
                            COMERCIALComboBox.Text = "RAFAEL"
                        Case "RAFAEL"
                            COMERCIALComboBox.Text = "ADELAINE"
                    End Select
                End If
                RAZAOTextBox.Focus()
                End If
        End If
    End Sub
    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        If OPERADORComboBox.Text = "" Then
            MsgBox("FAVOR INFORMAR O NOME DO OPERADOR")
        Else
            CADASTROTableAdapter.FillByOPERADOR(CADASTRODataSet.CADASTRO, OPERADORComboBox.Text)
        End If
    End Sub
    Private Sub CADASTRODataGridView_DataBindingComplete(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewBindingCompleteEventArgs)
        Label2.Text = "Total de : " & CADASTRODataGridView.Rows.Count & " registros"
    End Sub
    Private Sub Button14_Click(sender As System.Object, e As System.EventArgs) Handles Button14.Click
        If COMERCIALComboBox.Text = "" Then
            MsgBox("Favor preencher o nome do comercial", MsgBoxStyle.Information, "Atenção")
        Else
            Try
                CADASTROTableAdapter.FillByCOMERCIAL(CADASTRODataSet.CADASTRO, COMERCIALComboBox.Text)
            Catch ex As Exception
                MsgBox("Erro na pesquisa " + Environment.NewLine + ex.ToString, MsgBoxStyle.Information, "Atenção")
            End Try
        End If
    End Sub
End Class